package eleanor.ltd.isRealEstate.components;

import java.util.Date;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.runtime.Component;
import org.apache.tapestry5.services.ComponentSource;

import eleanor.ltd.isRealEstate.dao.pages.PagesDAO;
import eleanor.ltd.isRealEstate.entities.user.User;
import eleanor.ltd.isRealEstate.pages.Login;
import eleanor.ltd.isRealEstate.services.Authenticator;

@Import(stylesheet= {
		"context:adminica/js/fancybox/jquery.fancybox-1.3.4.css",
		"context:adminica/js/uniform/css/uniform.default.css",
		"context:adminica/js/tipsy/css/tipsy.css",
		"context:adminica/js/tinyeditor/style.css",
		"context:adminica/js/jqueryFileTree/jqueryFileTree.css",
		"context:adminica/js/slidernav/slidernav.css",
		"context:adminica/js/syntax_highlighter/styles/shCore.css",
		"context:adminica/js/syntax_highlighter/styles/shThemeDefault.css",
//		"context:adminica/js/uitotop/css/ui.totop.css",
//		"context:adminica/css/all.css",
		"context:adminica/css/reset.css",
		"context:adminica/css/text.css",
		"context:adminica/css/grid.css",
		"context:adminica/css/jqueryui.css",
		"context:adminica/css/main.css",
		"context:adminica/css/theme/theme_base.css",
		"context:adminica/css/buttons.css"
}, library = {
		"context:adminica/js/uniform/jquery.uniform.js",
		"context:adminica/js/livevalidation/livevalidation_standalone.js",
		"context:adminica/js/tipsy/jquery.tipsy.js",
		"context:adminica/js/iPhone/jquery.iphoneui.js",
		"context:adminica/js/jQuery151.js",
		"context:adminica/js/jQueryUI.js",
		"context:adminica/js/fancybox/jquery.fancybox-1.3.4.js",
		"context:adminica/js/quicksand/jquery.quicksand.js",
		"context:adminica/js/quicksand/custom_sorter.js",
		"context:adminica/js/quicksand/dash_sorter.js",
		"context:adminica/js/quicksand/jquery-animate-css-rotate-scale.js",
		"context:adminica/js/tinyeditor/tinyeditor.js",
		"context:adminica/js/jqueryFileTree/jqueryFileTree.js",
		"context:adminica/js/DataTables/jquery.dataTables.js",
		"context:adminica/js/slidernav/slidernav.js",
		"context:adminica/js/adminica/adminica_ui.js"
})
public class Atemplate {

	@Property
    @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
    private String title;

	@Property
    @Parameter(defaultPrefix = BindingConstants.LITERAL)
    private Block afterName;
	
    @Property
    private String pageName;
    
    @Property
    @Parameter(defaultPrefix = BindingConstants.LITERAL)
    private String sidebarTitle;

    @Property
    @Parameter(defaultPrefix = BindingConstants.LITERAL)
    private Block sidebar;

    @Inject
    private ComponentResources resources;
    
    @Property
	private String username;

    @Property
    @Inject
    @Symbol(SymbolConstants.APPLICATION_VERSION)
    private String appVersion;
    
    @Inject
    private Authenticator authenticator;
    
    @Inject
    private PagesDAO pagesDAO;
    
    @Property
    @SessionState
    private User user;
    
    private ComponentSource compSource;
 
    public String getClassForPageName()
    {
        return resources.getPageName().equalsIgnoreCase(pageName)
                ? "current_page_item"
                : null;
    }

    public String[] getPageNames()
    {
        return new String[]{"Index", "About", "Contact"};
    }
    
    public Date getCurrentTime()
    {
        return new Date();
    }
    
    void setupRender() {
//    	Class pageClass = compSource.getActivePage().getClass();	
//    	String pageClassS = pageClass.getName();
    	System.out.println(" NAZIV STRANICE  NAZIV STRANICE  NAZIV STRANICE  NAZIV STRANICE  NAZIV STRANICE : " + afterName);
//    	String path = pagesDAO.findByPath(pagesName).getPathOfPage();
//    	
//    	System.out.println("Component: " + pageComp.toString() + " Path from DB: " + path);
//    	if(pageComp.toString() == path) {
//    		title = pagesDAO.findByPath(pagesName).getNameOfPage();
//    		return null;
//    	}
    
    }
    
}
